package btanalyzer.core;

import org.springframework.beans.factory.FactoryBean;

import btanalyzer.core.config.DiggerSpringBean;
import btanalyzer.core.config.SpringContextManager;

public class DiggerSpringFactoryBean implements FactoryBean<Digger> {
	
	SpringContextManager ctxManager = new SpringContextManager();
	
	public DiggerSpringFactoryBean() {
		ctxManager.start();
	}

	public Digger getObject() throws Exception {
		return new DiggerSpringBean(ctxManager.getBean(Digger.class));
	}

	public Class<?> getObjectType() {
		return Digger.class;
	}

	public boolean isSingleton() {
		return true;
	}
	
	public void close() {
		ctxManager.stop();
	}

}
